﻿
Imports System.Text

Public Class systemMessages
    '  WithEvents _common As New Common
    ' WithEvents _gsettings As GeneralSettings = GeneralSettings.Instance
    Dim sb As New StringBuilder
    Private Sub MessageChanged(ByVal sender As Object, ByVal e As EventArgs) ' Handles _common.updateMessage
        If True Then ' _gsettings.SysMessageDateTime Then
            ' sb.AppendLine("[" & Date.Now & "] " & e.StringMessage)
        Else
            '  sb.AppendLine(e.StringMessage)
        End If
        If sb.Length > 100 Then ' _gsettings.SysMessageMaxSize Then
            Dim tempString As String = sb.ToString.Substring(sb.Length - 500)
            sb.Clear()
            sb.Append("[" & Date.Now.ToString & "] << SysMessage Max >>" & System.Environment.NewLine)
            sb.AppendLine(tempString)
        End If
        If tbMessage.InvokeRequired Then
            tbMessage.Invoke(New EventHandler(AddressOf setText))
        Else
            If chkAllowStreaming.Checked And True Then '_gsettings.SystemPAnelVisible Then
                tbMessage.Text = sb.ToString
                If chkAutoScroll.Checked Then
                    tbMessage.SelectionLength = 0
                    tbMessage.SelectionStart = tbMessage.Text.Length
                    tbMessage.ScrollToCaret()
                End If
            End If
        End If

    End Sub
    Private Sub setText(ByVal sender As Object, ByVal e As EventArgs)
        tbMessage.Text = sb.ToString
        If chkAutoScroll.Checked Then
            tbMessage.SelectionLength = 0
            tbMessage.SelectionStart = tbMessage.Text.Length
            tbMessage.ScrollToCaret()
        End If
    End Sub
    Private Sub Button1_Click(sender As System.Object, e As System.EventArgs) Handles Button1.Click
        'Common.SystemMessage() = "~~~~~"
    End Sub

    Public Sub New()

        ' This call is required by the designer.
        InitializeComponent()
        'tbMessage.Text = Common.SystemMessage
        'chkAllowStreaming.Checked = _gsettings.SystemMessageVerbose
        ' Add any initialization after the InitializeComponent() call.

    End Sub
    Private Sub ChangeAllowStreaming(ByVal sender As Object, ByVal e As EventArgs) 'Handles _gsettings.SystemMessageVerboseHasChanged
        chkAllowStreaming.Checked = True 'e.BoolVal
    End Sub
End Class
